package com.woniu.command.handle;

import com.woniu.adapter.PurchaseAdapter;
import com.woniu.outlet.po.PurchasePo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PurchaseCommandHandle {

    @Autowired
    private PurchaseAdapter purchaseAdapter;

    //添加采购单
    public Integer addPur(PurchasePo po){
        try {
            purchaseAdapter.addPurchasePo(po);
            return 1;
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
    }

    //修改采购单
    public Integer updatePur(PurchasePo po){
        try {
            purchaseAdapter.updatePurchase(po);
            return 1;
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
    }

    //删除采购单
    public String delete(Long id){
        String msg = purchaseAdapter.deletePurchase(id);
        return msg;
    }

    //提交采购单
    public Integer updatePurStatus(PurchasePo po,String name){
        po.setFixPerson(name);
        Integer integer = purchaseAdapter.updatePurchaseStatus(po);
        return integer;
    }

    //修改采购单状态
    public Integer updatePurStatus(Long id,String status){
        try {
            purchaseAdapter.update(id,status);
            return 1;
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
    }
}
